package org.easymodelers.gmf.creator.template.element;

import java.util.Map;

import org.easymodelers.gmf.creator.template.AbstractGraphTemplateBasedElementDefinitionHandler;
import org.easymodelers.modeler.data.ElementDefinition;

public class LabelTemplateBasedGraphHandler extends AbstractGraphTemplateBasedElementDefinitionHandler {

	protected String getTemplatePath() {
		return "/org/easymodelers/gmf/creator/template/element/label-graph.xml";
	}

	private String firstUpper(String s) {
		return s.substring(0, 1).toUpperCase() + s.substring(1);
	}
	
	protected void initializeContextForElementDefinition(ElementDefinition definition, Map<String, Object> context) {
		ElementDefinition parentDefinition = definition.getParent(); 

		LabelTypeData data = new LabelTypeData();
		data.setFigureDescriptorName(parentDefinition.getAttributes().get("name")+"FigureDescriptor");
		data.setFigureName(parentDefinition.getAttributes().get("name")+"Figure");
		data.setLabelName(definition.getAttributes().get("name")+"Figure");
		data.setLabelAccessorName("getFigure"+firstUpper(definition.getAttributes().get("name"))+"Figure");
		data.setNodeName(parentDefinition.getAttributes().get("name")+"Node");
		data.setLabelNodeName(definition.getAttributes().get("name")+"Node");

		context.put("data", data);
	}

}
